<?php
require_once ROOT_APPLICATION_MODULES_ADMIN_MODELS.DS."Categorys.php";
require_once ROOT_LIBRARY_UTILITY.DS."Converter.php";

class Application_Forms_Article_Revision extends Zend_Form
{
    public function init()
    {
        $this->setName('news_article_revision');

        /* Hiden field, some field use in future extend */
        
        $revision_id = new Zend_Form_Element_Hidden('revision_id');
        $article_id = new Zend_Form_Element_Hidden('article_id');
        $slug = new Zend_Form_Element_Hidden('slug');
        $icons = new Zend_Form_Element_Hidden('icons');
        $created_date = new Zend_Form_Element_Hidden('created_date');
        $created_user_id = new Zend_Form_Element_Hidden('created_user_id');
        $created_user_name = new Zend_Form_Element_Hidden('created_user_name');
     
        /* Visible field */

        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Main title')
              ->setRequired(true)
              ->addFilter('StripTags')
              ->addValidator('NotEmpty');

        $sub_title = new Zend_Form_Element_Text('sub_title');
        $sub_title->setLabel('Sub title:')
              ->setRequired(false)
              ->addFilter('StripTags');
             
        $description = new Zend_Form_Element_Textarea('description');
        $description->setLabel('Description:')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addValidator('NotEmpty');
			   
        $content = new Zend_Form_Element_Textarea('content');
        $content->setLabel('Content:')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addValidator('NotEmpty');			   
               
        $author = new Zend_Form_Element_Text('author');
        $author->setLabel('Author:')
              ->setRequired(true)
              ->addFilter('StripTags');               

		$category = new Zend_Form_Element_Select('category_id');
		$category->setLabel('Category:');	
       
		
		/* Submit button */
	   
        $submit = new Zend_Form_Element_Submit('Restore');
        $submit->setAttrib('id', 'submitbutton');
		
		$preview = new Zend_Form_Element_Submit('Preview');
        $preview->setAttrib('id', 'previewbutton');
        
        $delete = new Zend_Form_Element_Submit('Delete');
        $delete->setAttrib('id', 'deleteButton');
		
		/* Load form data */
		
		/* Language */
		
		/* Category */
        
        $category_model = new End_Models_Categorys();
        $categories = $category_model->fetchAll();
        foreach($categories as $c) {
        	$category->addMultiOption($c->category_id,
        		$c->name);
        }
		

        $this->addElements(array($title, $sub_title, $category,
			$description, $content, $author, 
			$submit, $preview, $delete,
			$revision_id, $article_id, $slug, $icons, $created_date,
			$created_user_id, $created_user_name));
    }
}